package com.yshy.moviechoseseatinginnerapi.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yshy.moviechoseseatinginnerapi.service.CitiesService;
import com.yshy.moviechoseseatingcommon.entity.bo.cities.ListByProvinceCodeBo;
import com.yshy.moviechoseseatingcommon.entity.bo.cities.LocateByLongitudeAndLatitudeBo;
import com.yshy.moviechoseseatingcommon.entity.vo.cities.*;
import com.yshy.moviechoseseatingcommon.util.RequstUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author :
 * @desc :
 * @create: 下午3:50
 **/
@Service
public class CitiesServiceImpl implements CitiesService {
    @Autowired
    private RequstUtil requstUtil;
    @Override
    public String v1ListAll() {
        V1ListAllVo v1listAllVo = requstUtil.citiesV1ListAll();
        if(v1listAllVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(v1listAllVo, SerializerFeature.WriteMapNullValue);
    }

    @Override
    public String v2ListAll() {
        V2ListAllVo v2ListAllVo = requstUtil.citiesV2ListAll();
        if(v2ListAllVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(v2ListAllVo,SerializerFeature.WriteMapNullValue);
    }

    @Override
    public String locateByLongitudeAndLatitude( LocateByLongitudeAndLatitudeBo bo) {
        LocateByLongitudeAndLatitudeVo locateByLongitudeAndLatitudeVo = requstUtil.citiesLocateByLongitudeAndLatitude(bo);
        if(locateByLongitudeAndLatitudeVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(locateByLongitudeAndLatitudeVo,SerializerFeature.WriteMapNullValue);
    }

    @Override
    public String provincesListAll() {
        ProvincesListAllVo provincesListAllVo = requstUtil.citiesProvincesListAll();
        if(provincesListAllVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(provincesListAllVo,SerializerFeature.WriteMapNullValue);
    }

    @Override
    public String listByProvinceCode( ListByProvinceCodeBo bo) {
        ListByProvinceCodeVo listByProvinceCodeVo = requstUtil.citiesListByProvinceCode(bo);
        if(listByProvinceCodeVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(listByProvinceCodeVo,SerializerFeature.WriteMapNullValue);
    }
}
